package com.wechat.backend.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.config.annotation.*;

@Configuration
@EnableWebSocket
public class WebSocketConfig implements WebSocketConfigurer {
    private final com.wechat.backend.ws.ChatWebSocketHandler chatWebSocketHandler;

    public WebSocketConfig(com.wechat.backend.ws.ChatWebSocketHandler chatWebSocketHandler) {
        this.chatWebSocketHandler = chatWebSocketHandler;
    }

    @Override
    public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
        registry.addHandler(chatWebSocketHandler, "/ws/chat/{userId}")
                .setAllowedOrigins("*");
    }
} 